package com.ncloud.product.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.ncloud.product.entity.DiscntComp;

@Mapper
public interface DiscntCompMapper {

	@Select("select * from bs_p_discnt_comp where discnt_id = #{discntId} and eff_flag = '1' order by order_no")
	@Results({ @Result(column = "comp_inst_id", property = "compInstId"),
			@Result(column = "discnt_id", property = "discntId"), @Result(column = "order_no", property = "orderNo"),
			@Result(column = "band_width", property = "bandWidth"),@Result(column = "node_type", property = "nodeType"),
			@Result(column = "rsrv_str1", property = "rsrvStr1"), @Result(column = "rsrv_str2", property = "rsrvStr2"),
			@Result(column = "rsrv_str3", property = "rsrvStr3"), @Result(column = "rsrv_str4", property = "rsrvStr4"),
			@Result(column = "rsrv_str5", property = "rsrvStr5"),
			@Result(column = "allot_price", property = "allotPrice"),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "create_user", property = "createUser"),
			@Result(column = "update_time", property = "updateTime"),
			@Result(column = "update_user", property = "updateUser"), @Result(column = "remark", property = "remark") })
	List<DiscntComp> getDiscntComp(Long discntId);

	@Select("select node_type,band_width,count(1) as count from bs_p_discnt_comp where discnt_id = #{discntId} and eff_flag = '1' group by node_type,band_width")
	@Results({ @Result(column = "band_width", property = "bandWidth"),
			@Result(column = "node_type", property = "nodeType"), @Result(column = "count", property = "count")})
	List<Map<String, Object>> getCompCountByDiscnt(Long discntId);

}
